//
//  perNikeNameController.m
//  YiXiu
//
//  Created by ZHY on 16/7/8.
//  Copyright © 2016年 zzz. All rights reserved.
//

#import "perNikeNameController.h"

@interface perNikeNameController ()

@property (nonatomic, strong) UITextField  *nikeField;


@end

@implementation perNikeNameController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];
    
    //设置输入框
    [self setUpTextField];
    //设置确认按钮
    [self setUpSureBtn];
   
    
}





-(void)setUpTextField{
    
    //1.设置昵称修改的输入框
    UITextField * nikeField = [[UITextField alloc]init];
    nikeField.frame = CGRectMake(15,64+30, KScreenWidth-30, 35);
    nikeField.placeholder = @"请输入您想要修改的昵称";
    nikeField.font = [UIFont fontWithName:@"一羞" size:15];
    //2.设置输入框样式
    nikeField.borderStyle = UITextBorderStyleRoundedRect;
    //再次点击全部删除
    nikeField.clearButtonMode = YES;
    
    _nikeField = nikeField;
    
    [self.view addSubview:nikeField];
    
    
    
    
}



-(void)setUpSureBtn{
    
    //1.设置按钮
    UIButton * sureBtn = [[UIButton alloc]init];
    sureBtn.frame = CGRectMake( KScreenWidth-80, 64+30+35+30, 60, 20);
    sureBtn.backgroundColor = [UIColor blackColor];
    [sureBtn setTitle:@"确定修改" forState:UIControlStateNormal];
    sureBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [sureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [sureBtn addTarget:self action:@selector(sureAction:) forControlEvents:UIControlEventTouchUpInside];
//    self.navigationItem.rightBarButtonItem = sureBtn;
    [self.view addSubview:sureBtn];
    
    
}






-(void)sureAction:(UIButton *)sender{
    
    

    
    [UIAlertController showAlertViewWithTitle:@"是否确定修改您的昵称" message:nil cancle:@"取消" sureTitle:@"确定" sureAction:^(UIAlertAction *action) {
        
        
        [self.navigationController popViewControllerAnimated:YES];  //返回上一页
    
        [[UserModel sharedUserModel] setName:self.nikeField.text];
    
        if (self.Block) {
            self.Block(self.nikeField.text);
        }
            
    }];
    
    
    
    
    
}





@end
